package com.zuo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zuo.dao.LoginTableMapper;
import com.zuo.dao.UserMapper;
import com.zuo.model.LoginTable;
import com.zuo.model.User;
import com.zuo.service.LoginService;

@Service("loginService")
public class LoginServiceImpl implements LoginService {
	
	@Autowired
	private UserMapper userdao;
	
	@Autowired
	private LoginTableMapper login;
	
	
	@Override
	public User getUserByUserName(String username) {
		return userdao.selectByUserName(username);
	}

	@Override
	public List<User> getUsers() {
		return userdao.getUsers();
	}

	@Override
	public LoginTable getLoginTimeByUserName(String username) {
		return login.selectByUserName(username);
	}

	@Override
	public String checkPassword(String username, String password) {
		User user = this.getUserByUserName(username);
		if(user == null )
			return "用户名不存在！";
		if(!password.equals(user.getPassword()))
			return "密码不正确！";
		System.out.println("密码检验通过");
		return null;
	}

}
